//package com.bxj.wxtt.controller;
//
//import ch.qos.logback.classic.Level;
//import ch.qos.logback.classic.Logger;
//import ch.qos.logback.classic.LoggerContext;
//import com.ifeng.fread.audio.book.api.bo.AudioBookBO;
//import com.ifeng.fread.audio.book.api.service.IAudioBookDubboService;
//import org.slf4j.LoggerFactory;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//
///**
// * Created by baixiujiang on 17/10/15.
// */
//@Controller
//@RequestMapping(value = "/audio_book")
//@EnableScheduling
////@PropertySource(value = {"classpath:application.properties", "file:///ifeng/comic/config/core.properties"},encoding="utf-8")
//public class AudioBookController {
//
//    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
//    Logger logger = loggerContext.getLogger(AudioBookController.class);
//
//    @Resource
//    IAudioBookDubboService audioBookDubboService;
//
//
//    @PostConstruct
//    public void init() {
////        logger.debug("loggingPath:", loggingPath);
////        logger.debug("loggingLevelRoot:", loggingLevelRoot);
////        logger.debug("build.version:", env.getProperty("build.version"));
//
//    }
//
//    @RequestMapping(value = {"/audio_book"}, method = RequestMethod.GET)
//    public @ResponseBody AudioBookBO getAudioBook(Integer id) {
//        return audioBookDubboService.getAudioBookById(id);
//    }
////
////    @RequestMapping(value = {"/addCache"}, method = RequestMethod.GET)
////    @MatrixAddCache(prefix = "data_is_on_platform_charge", key = "#key")
////    @ResponseBody
////    public String addCache(String prefix, String key, String value) {
////        return value;
////    }
////
////    @RequestMapping(value = {"/delCache"}, method = RequestMethod.GET)
////    public ResponseEntity delCache(String prefix, String key) {
////        String result = "Failed";
////        if (matrixCache.exists(prefix, key.split(":"))) {
////            result = "OK";
////            matrixCache.delCache(prefix, key.split(":"));
////        }
////        return new ResponseEntity(result, HttpStatus.OK);
////    }
////
////    @RequestMapping(value = {"/add_property"}, method = RequestMethod.GET)
////    public ResponseEntity addProperty(String key, String value) {
////        System.setProperty(key, value);
//////        propertyPlaceholderConfigurer.setProperties();
////        return new ResponseEntity("", HttpStatus.OK);
////    }
////
//////    @RequestMapping(value = {"/test_comic"}, method = RequestMethod.GET)
//////    public ResponseEntity testComic(Integer comicId) {
//////        return new ResponseEntity(JSON.toJSONString(comicDubboService.getComicById(comicId)), HttpStatus.OK);
//////    }
////
////    @RequestMapping(value = {"/set_config"}, method = RequestMethod.GET)
////    public ResponseEntity set_config(String module, String key, String value, String defaultValude) {
////        return new ResponseEntity((configDubboService.setStringConfig(module, key, value, defaultValude)), HttpStatus.OK);
////    }
////
////    @RequestMapping(value = {"/get_config"}, method = RequestMethod.GET)
////    public ResponseEntity get_config(String module, String key, String defaultValue) {
////
////        return new ResponseEntity((configDubboService.getStringConfig(module, key, defaultValue)), HttpStatus.OK);
////    }
////
////    @RequestMapping(value = {"/delCacheByKeys"}, method = RequestMethod.GET)
////    public ResponseEntity get_config(String prefix, List<String> keys) {
////        matrixCache.delCache(prefix, keys.toArray(new String[0]));
////        return new ResponseEntity("OK", HttpStatus.OK);
////    }
////
////    @RequestMapping(value = {""}, method = RequestMethod.GET)
////    public ModelAndView test(ModelMap modelMap) {
////        List<HashMap<String, Object>> listMap = new ArrayList<HashMap<String, Object>>();
////        List<String> listConfig = configDubboService.getListConfig("cache_list", "1");
////        for (String value : listConfig) {
////            HashMap<String, Object> map = new HashMap<String, Object>();
////            map.put("name", configDubboService.getStringConfig(value, "name", ""));
////            map.put("prefix", configDubboService.getStringConfig(value, "prefix", ""));
////            map.put("value", configDubboService.getStringConfigDefaultValue(value, "prefix", ""));
////            map.put("url", configDubboService.getStringConfig(value, "url", ""));
////            List<String> keyConfigList = configDubboService.getListConfig(value, "keys");
////            List<HashMap<String, Object>> listConfigMap = new ArrayList<HashMap<String, Object>>();
////            for (String keyConfig : keyConfigList) {
////                HashMap<String, Object> keyMap = new HashMap<String, Object>();
////                keyMap.put("name", configDubboService.getStringConfig(keyConfig, "name", ""));
////                keyMap.put("id", configDubboService.getStringConfig(keyConfig, "id", ""));
////                keyMap.put("title", configDubboService.getStringConfig(keyConfig, "title", ""));
////                keyMap.put("value", configDubboService.getStringConfigDefaultValue(keyConfig, "title", ""));
////                listConfigMap.add(keyMap);
////            }
////            map.put("keys", listConfigMap);
////            listMap.add(map);
////        }
////
////        modelMap.addAttribute("listMap", listMap);
////        modelMap.addAttribute("comicVersion", comicVersion);
////        return new ModelAndView("test");
////    }
////
////    @RequestMapping(value = {"manager"}, method = RequestMethod.GET)
////    public ModelAndView manager(ModelMap modelMap) {
////        List<HashMap<String, Object>> listMap = new ArrayList<HashMap<String, Object>>();
////        List<String> listConfig = configDubboService.getListConfig("cache_list", "1");
////        for (String value : listConfig) {
////            HashMap<String, Object> map = new HashMap<String, Object>();
////            map.put("id", value);
////            map.put("name", configDubboService.getStringConfig(value, "name", ""));
////            map.put("prefix", configDubboService.getStringConfig(value, "prefix", ""));
////            map.put("value", configDubboService.getStringConfigDefaultValue(value, "prefix", ""));
////            map.put("url", configDubboService.getStringConfig(value, "url", ""));
////            List<String> keyConfigList = configDubboService.getListConfig(value, "keys");
////            List<HashMap<String, Object>> listConfigMap = new ArrayList<HashMap<String, Object>>();
////            for (String keyConfig : keyConfigList) {
////                HashMap<String, Object> keyMap = new HashMap<String, Object>();
////                keyMap.put("name", configDubboService.getStringConfig(keyConfig, "name", ""));
////                keyMap.put("id", configDubboService.getStringConfig(keyConfig, "id", ""));
////                keyMap.put("title", configDubboService.getStringConfig(keyConfig, "title", ""));
////                keyMap.put("value", configDubboService.getStringConfigDefaultValue(keyConfig, "title", ""));
////                listConfigMap.add(keyMap);
////            }
////            map.put("keys", listConfigMap);
////            listMap.add(map);
////        }
////
////        modelMap.addAttribute("listMap", listMap);
////        return new ModelAndView("manager");
////    }
////
////    @RequestMapping(value = {"manager/add"}, method = RequestMethod.GET)
////    public ResponseEntity manager_add(CacheParam param) {
////        String functionKey = UUID.randomUUID().toString();
////        configDubboService.addListConfig("cache_list", "1", functionKey, "");
////        configDubboService.setStringConfig(functionKey, "name", param.getName(), "");
////        configDubboService.setStringConfig(functionKey, "url", param.getUrl(), "");
////        configDubboService.setStringConfig(functionKey, "prefix", "prefix", param.getPrefix());
////        for (Param key : param.getKeys()) {
////            String paramKey = UUID.randomUUID().toString();
////            configDubboService.addListConfig(functionKey, "keys", paramKey, "");
////            configDubboService.setStringConfig(paramKey, "title", key.getName(), key.getValue());
////        }
////        return new ResponseEntity("OK", HttpStatus.OK);
////    }
////
////
////    @RequestMapping(value = {"manager/del"}, method = RequestMethod.GET)
////    public ResponseEntity manager_del(CacheParam param) {
////        String value = param.getId();
////        configDubboService.delListItemConfig("cache_list", "1", value);
////        configDubboService.delStringConfig(value, "name");
////        configDubboService.delStringConfig(value, "url");
////        configDubboService.delStringConfig(value, "prefix");
////        List<String> keyConfigList = configDubboService.getListConfig(value, "keys");
////        configDubboService.delListConfig(value, "keys");
////        for (String keyConfig : keyConfigList) {
////            configDubboService.delStringConfig(keyConfig, "name");
////            configDubboService.delStringConfig(keyConfig, "id");
////            configDubboService.delStringConfig(keyConfig, "title");
////        }
////        return new ResponseEntity("OK", HttpStatus.OK);
////    }
////
////
//    @RequestMapping(value = {"exception"}, method = RequestMethod.GET)
//    public ResponseEntity exception() throws Exception {
//        throw new Exception("exception");
//    }
//
//
//    /**
//     * 动态设置日志级别
//     *
//     * @param name
//     * @param level
//     * @return
//     */
//    @RequestMapping(value = {"/set_log_level"}, method = RequestMethod.GET)
//    public ResponseEntity setLogLevel(String name, String level) {
//        Logger logger = loggerContext.getLogger(name);
//        logger.setLevel(Level.toLevel(level));
//        return new ResponseEntity("", HttpStatus.OK);
//    }
//    @RequestMapping(value = {"/log"}, method = RequestMethod.GET)
//    public ResponseEntity log(String level) {
//        switch(Level.toLevel(level).toInteger()) {
//            case Level.TRACE_INT:
//                logger.trace("trace");
//                break;
//            case Level.DEBUG_INT:
//                logger.debug("debug");
////                break;
//            case Level.WARN_INT:
//                logger.warn("warn");
////                break;
//            case Level.INFO_INT:
//                logger.info("info");
////                break;
//            case Level.ERROR_INT:
//                logger.error("error");
//        }
//        return new ResponseEntity("", HttpStatus.OK);
//    }
//
//
////    @Scheduled(cron = "*/4 * * * * *")
//    public void run() {
//        logger.trace("trace");
//        logger.debug("debug");
//        logger.warn("warn");
//        logger.info("info");
//        logger.error("error");
//    }
//}
